const { app, BrowserWindow } = require('electron/main');
const isDev = require('electron-is-dev');
const path = require('node:path')

//创建窗口的方法
const createWindow = () => {
    let win = new BrowserWindow({
        width: 800,
        height: 600,
        title: '标题',
        show: false,
        webPreferences: {
            preload: path.join(__dirname, 'preload.js'),
            // nodeIntegration:true,
        }
    })

    const urlLocation = isDev ? 'http://localhost:3000' : 'myUrl';
    win.loadURL(urlLocation)

    win.once('ready-to-show', () => {
        win.show()
      })

    // win.loadFile('index.html');

    win.webContents.openDevTools()
}

app.on('ready', () => {
    console.log('ready')
    createWindow()
})

//所有窗口关闭
app.on('window-all-closed', () => {
    if (process.platform !== 'darwin') {
        app.quit()
    }
})